package com.example.demo.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.dao.AqiDao;
import com.example.demo.pojo.Aqi;
import com.example.demo.vos.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;

@Primary
@Service
public class AqiServiceImpl implements IAqiService {

    @Autowired
    private AqiDao aqiDao;

    @Override
    public ResultVo getAqiById(Integer aqiId) {
        Aqi aqi = aqiDao.selectById(aqiId);
        return aqi != null ? ResultVo.success(aqi) : ResultVo.failure("AQI信息不存在");
    }

    @Override
    public ResultVo listAqiAll() {
        QueryWrapper<Aqi> qw = new QueryWrapper<>();
        qw.orderByAsc("aqi_id");
        List<Aqi> list = aqiDao.selectList(qw);
        return ResultVo.success(list);
    }


}
